<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <input type="text" v-focus>
        <input type="text" v-color="'red'">
        
    </div>
    <script src="../node_modules/vue/dist/vue.js"></script>
    <script>
        Vue.directive('focus',{
            inserted:function(el){
                // el表示指令所绑定的元素
                el.focus();
            }
        })
        // 带参数的自定义指令
        // Vue.directive('color',{
        //     inserted:function(el,binding){
        //         el.style.backgroundColor = binding.value;
        //     }
        // })
        var vm = new Vue({
            el:'#app',
            data:{

            },
            methods: {
                
            },
            // 局部指令
            directives:{
                color:{
                    inserted: function (el, binding) {
                        el.style.backgroundColor = binding.value;
                    }
                }
            }
        })

        
    </script>
</body>
</html>